<template>
  <div>
    <div class="back" @click="goBack">
      <van-icon color="#fff" name="arrow-left" />
    </div>
    <div class="header-btn">
      <div class="content-title">礼券兑换</div>
    </div>
    <!-- tab切换 -->
    <van-nav-bar title="我的订单" />
    <van-sticky>
      <van-tabs v-model="active" animated>
        <van-tab
          :to="item.path"
          v-for="(item, index) in navtab"
          :key="index"
          :title="item.title"
        >
        </van-tab>
      </van-tabs>
    </van-sticky>
    <router-view></router-view>
    <!-- 底部button -->
    <div class="bottom-btn" @click="exchange">
      <div class="address-btn">
        <span>兑换</span>
      </div>
    </div>
  </div>
</template>

<script>
import { Toast } from 'vant';
export default {
  data() {
    return {
      active: 2,
      navtab: [
        { title: "茶饮订单", path: "/giftexchange/discount" },
        { title: "百货订单", path: "/giftexchange/departmentstores" },
      ],
      code: ''
    };
  },
  methods: {
    goBack() {
      this.$router.push('/');
    },
    exchange() {
        if (this.code === '') {
            Toast('兑换失败');
        } else {
            Toast('兑换成功');
        }
    }
  }
};
</script>

<style lang="less" scoped>
.header-btn {
  height: 50px;
  width: 100%;
  background-color: #fff;
  border-bottom: 1px solid #e8e7e7;
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: 0;
  .content-title {
    font-size: 17px;
    font-weight: 600;
  }
}
.back {
  position: fixed;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-color: rgba(0, 0, 0, 0.3);
  text-align: center;
  line-height: 30px;
  top: 10px;
  left: 10px;
  z-index: 999;
}

.bottom-btn {
  width: 100%;
  height: 60px;
  position: fixed;
  bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  .address-btn {
    width: 90%;
    height: 50px;
    border-radius: 25px;
    background-color: #143ea9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    color: #fff;
  }
}
</style>

<style>
.van-tabs--line .van-tabs__wrap {
  height: 55px;
}

.van-tabs__line {
  bottom: 26px;
  border-radius: 0;
}

.van-tabs__line {
  background-color: #0151c6;
}
</style>
